
<%--
  Created by IntelliJ IDEA.
  User: zzz
  Date: 2020/2/7
  Time: 21:41
  To change this template use File | Settings | File Templates.
--%>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="utf-8" />
    <title>cart</title>
    <link rel="stylesheet" type="text/css" href="${APP_PATH}/portal/css/public.css"/>
    <link rel="stylesheet" type="text/css" href="${APP_PATH}/portal/css/proList.css" />
</head>
<body>
<!--------------------------------------cart--------------------->
<jsp:include page="/WEB-INF/jsps/Portal/common/top.jsp"/>
<span hidden id="path">${APP_PATH}/</span>
<div class="cart mt">
    <!-----------------logo------------------->
    <!--<div class="logo">
        <h1 class="wrapper clearfix">
            <a href="index.html"><img class="fl" src="img/temp/logo.png"></a>
            <img class="top" src="img/temp/cartTop01.png">
        </h1>
    </div>-->
    <!-----------------site------------------->
    <div class="site">
        <p class=" wrapper clearfix">
            <span class="fl">购物车</span>
            <img class="top" src="${APP_PATH}/portal/img/temp/cartTop01.png">
            <a href="${APP_PATH}/toPortal" class="fr">继续购物&gt;</a>
        </p>
    </div>
    <!-----------------table------------------->
    <div id="preList" class="table wrapper">
        <div class="tr">
            <div>商品</div>
            <div>单价</div>
            <div>数量</div>
            <div>小计</div>
            <div>操作</div>
        </div>

        <c:forEach items="${requestScope.trolleyInfoList}" var="trolleyInfo">
            <div class="th">
                <div class="pro clearfix">
                    <label class="fl">
                        <input value="${trolleyInfo.pre_order.poid}" type="checkbox"/>
                        <span></span>
                    </label>
                    <a class="fl" href="${APP_PATH}/toFurnitureDetail?ktid=${trolleyInfo.furniture.kt_ktid}&fid=${trolleyInfo.furniture.fid}">
                        <dl class="clearfix">
                            <dt class="fl"><img style="width: 120px;" src="${APP_PATH}/${trolleyInfo.furnitureKinds.fkface}"></dt>
                            <dd class="fl">
                                <p>${trolleyInfo.furniture.fname}</p>
                                <p>颜色分类:</p>
                                <p>${trolleyInfo.furnitureKinds.fkname}</p>
                            </dd>
                        </dl>
                    </a>
                </div>
                <div style="position: absolute; left: 660px;" class="price">￥<fmt:formatNumber type="number" value="${trolleyInfo.furnitureKinds.fkprice}" pattern="#.00" /></div>
                <div style="position: absolute; left: 865px;" class="number">
                    <p class="num clearfix">
                        <img class="fl sub" src="${APP_PATH}/portal/img/temp/sub.jpg">
                        <span id="${trolleyInfo.pre_order.poid}"class="fl preCount">${trolleyInfo.pre_order.count}</span>
                        <img class="fl add" src="${APP_PATH}/portal/img/temp/add.jpg">
                    </p>
                </div>
                <div style="position: absolute; left: 1095px;" class="price sAll">￥<fmt:formatNumber type="number" value="${trolleyInfo.pre_order.count * trolleyInfo.furnitureKinds.fkprice}" pattern="#.00" /></div>
                <div style="position: absolute; left: 1255px;" class="price"><a class="del" href="javascript:;">删除<span hidden class="deleteHref">${APP_PATH}/order/deletePre?poid=${trolleyInfo.pre_order.poid}</span></a></div>
            </div>
        </c:forEach>


        <div class="goOn">空空如也~<a href="${APP_PATH}/toPortal">去逛逛</a></div>
        <div class="tr clearfix">
            <label class="fl">
                <input class="checkAll" type="checkbox"/>
                <span></span>
            </label>
            <p class="fl">
                <a href="javascript:;">全选</a>
                <a href="javascript:;" class="del">删除<span hidden id="deletesHref">${APP_PATH}/order/deletePres</span></a>
            </p>
            <p class="fr">
                <span>共<small id="sl">0</small>件商品</span>
                <span>合计:&nbsp;<small id="all">￥0.00</small></span>
                <a onclick="toOrder()" class="count">结算</a>
            </p>
        </div>
    </div>
</div>
<div class="mask"></div>
<div class="tipDel">
    <p>确定要删除该商品吗？</p>
    <p class="clearfix">
        <a class="fl cer" href="javascript:;">确定</a>
        <a class="fr cancel" href="javascript:;">取消</a>
    </p>
</div>
<!--返回顶部-->
<jsp:include page="/WEB-INF/jsps/Portal/common/gotop.jsp"/>
<!--footer-->
<jsp:include page="/WEB-INF/jsps/Portal/common/bottom.jsp"/>
<!----------------mask------------------->
<div class="mask"></div>
<!-------------------mask内容------------------->
<jsp:include page="/WEB-INF/jsps/Portal/common/skimming.jsp"/>
<div class="pleaseC">
    <p>请选择宝贝</p>
    <img class="off" src="${APP_PATH}/portal/img/temp/off.jpg" />
</div>
<script src="${APP_PATH}/portal/js/jquery-1.12.4.min.js" type="text/javascript" charset="utf-8"></script>
<script src="${APP_PATH}/portal/js/public.js" type="text/javascript" charset="utf-8"></script>
<script src="${APP_PATH}/portal/js/pro.js" type="text/javascript" charset="utf-8"></script>
<script src="${APP_PATH}/portal/js/cart.js" type="text/javascript" charset="utf-8"></script>
</body>
</html>

<script>
$(function () {
    if($(".th").length==0){
        $(".table .goOn").show();
    }
    $(".sub , .add").click(function () {
        var poid = $(this).parent().find(".preCount").attr("id");
        var count = $(this).parent().find(".preCount").html();
        $.ajax({
            url : "${APP_PATH}/order/updatePre",
            method : "POST",
            data : {
                poid : poid,
                count : count
            }
        });
    });
});

function toOrder() {
    if($(".th input[type='checkbox']:checked").length==0){
        $(".mask").show();
        $(".pleaseC").show();
    }else{
        var poids = new Array();
        $(".th input[type='checkbox']:checked").each(function(j){
            var poid = $(this).val();
            poids.push(poid);
        });
        $.ajax({
            url : "${APP_PATH}/getAccountPre",
            method : "POST",
            data : {
                poids : poids
            },
            success : function () {
                window.location.href = "${APP_PATH}/toAccount";
            }
        });
    }
}
</script>